import Vue from 'vue'
import Vuex from 'vuex'

import user from './modules/user'
import layout from './modules/layout'
import tagsView from './modules/tagsView'
import getters from './getters'
import asyncRouter from './modules/async-router'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    isCollapse:false,
    globalLoading: false
  },
  mutations: {
    //同步修改state,都是方法
  // 第一个参数state,第二个参数是需要修改点值
    changeCollapse(state){
      console.log(state);
      state.isCollapse = !state.isCollapse
    },
    // 显示与关闭 全局 loading
    showLoading (state) {
      state.globalLoading = true
    },
    hideLoading (state) {
      state.globalLoading = false
    }
  },
  actions: {
     // 异步提交mutation
     // 定义全局loading 为false
  
  },
  modules: {
    // 模块化
    user,
    layout,
    tagsView,
    asyncRouter // 动态菜单
  },
  getters
  
})
